/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbean.SOP;

import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.model.SelectItem;
import merlion.crm.slcm.session.SLCSessionBeanLocal;
import merlion.crm.sopm.entity.SalesOrder;
import merlion.crm.sopm.session.SOPSessionBeanLocal;

/**
 *
 * @author Yuwei
 */
@ManagedBean(name = "ssoManagerBean")
@SessionScoped
public class SearchSOManagerBean {
    public static final String SO = "SO";
    
    @EJB
    private SLCSessionBeanLocal sLCSessionBean;
    @EJB
    private SOPSessionBeanLocal sOPSessionBean;
    private List<SalesOrder> sos;
    private SelectItem[] categoryOptions;
    private SelectItem[] statusOptions;
    private final static String[] categories;
    private final static String[] statuses;
    
    static{
        categories = new String[2];
        categories[0] = "WholeSale";
        categories[1] = "DirectSale";
        
        statuses = new String[7];
        statuses[0] = "Initiated";
        statuses[1] = "CreditChecking";
        statuses[2] = "ATPChecking";
        statuses[3] = "Confirmed&Fulfilling";//fulfilling
        statuses[4] = "Completed";
        statuses[5] = "Cancelled";
        statuses[6] = "Blocked";
    }
    /** Creates a new instance of SearchCustomerManagerBean */
    public SearchSOManagerBean() {
        sos = new ArrayList<SalesOrder>();
    }
    
     private SelectItem[] createFilterOptions(String[] data)  {  
        SelectItem[] options = new SelectItem[data.length + 1];  
  
        options[0] = new SelectItem("", "Select");  
        for(int i = 0; i < data.length; i++) {  
            options[i + 1] = new SelectItem(data[i], data[i]);  
        }  
  
        return options;  
    }

    public SelectItem[] getCategoryOptions() {
	    categoryOptions = createFilterOptions(categories);
        return categoryOptions;
    }

    public void setCategoryOptions(SelectItem[] categoryOptions) {
        this.categoryOptions = categoryOptions;
    }
    public SelectItem[] getStatusOptions(){
        statusOptions = createFilterOptions(statuses);
        return statusOptions;
    }

    public void setStatusOptions(SelectItem[] statusOptions) {
        this.statusOptions = statusOptions;
    }

    public List<SalesOrder> getSos() {
	sos = sOPSessionBean.getAllSalesOrders();
        return sos;
    }

    public void setSos(List<SalesOrder> sos) {
        this.sos = sos;
    }

    public SLCSessionBeanLocal getsLCSessionBean() {
        return sLCSessionBean;
    }

    public void setsLCSessionBean(SLCSessionBeanLocal sLCSessionBean) {
        this.sLCSessionBean = sLCSessionBean;
    }

    public SOPSessionBeanLocal getsOPSessionBean() {
        return sOPSessionBean;
    }

    public void setsOPSessionBean(SOPSessionBeanLocal sOPSessionBean) {
        this.sOPSessionBean = sOPSessionBean;
    }
     
}
